import { Input } from 'antd'
import { TablePageQueryItem, TablePageTableProps } from '@/components'
import { BooleanType } from '@/types'

export const useSystemProduct = () => {
  /**
   * 查询条件
   */
  const queryItems: TablePageQueryItem[] = [
    {
      label: '产品编码',
      name: 'productCode',
      children: <Input />,
    },
    {
      label: '产品名称',
      name: 'productName',
      children: <Input />,
    },
    {
      label: '状态',
      name: 'status',
      children: <Input />,
    },
  ]

  /**
   * 表格配置
   */
  const tableColumns: TablePageTableProps['columns'] = [
    {
      title: '产品编码',
      dataIndex: 'productCode',
      ellipsis: true,
      width: 200,
    },
    {
      title: '产品名称',
      dataIndex: 'productName',
      ellipsis: true,
      width: 200,
    },
    {
      title: '产品描述',
      dataIndex: 'description',
      ellipsis: true,
    },
    {
      title: '状态',
      dataIndex: 'status',
      ellipsis: true,
      render: (status: BooleanType) => {
        return status === 0 ? '停用' : '启用'
      },
    },
  ]

  return {
    tableColumns,
    queryItems,
  }
}
